pub struct Selections {
    selections: Vec<String>,
    index: usize,
}

impl Selections {
    pub fn new<I: IntoIterator<Item = String>>(selections: I) -> Self {
        Self {
            selections: selections.into_iter().collect(),
            index: 0,
        }
    }

    pub fn current(&self) -> &String {
        &self.selections[self.index]
    }

    pub fn nav_up(&mut self) {
        if let Some(ans) = self.index.checked_sub(1) {
            self.index = ans
        } else {
            self.index = self.selections.len() - 1;
        }
    }

    pub fn nav_down(&mut self) {
        let down = self.index + 1;
        if down >= self.selections.len() {
            self.index = 0;
        } else {
            self.index = down;
        }
    }
}